<?php
namespace app\api\controller;
use app\index\model\NewsModel;

/**
 * Created by PhpStorm.
 * User: chency
 * Date: 2018/11/10 0010
 * Time: 下午 12:07
 */
class Index extends Base{
    //用户同意授权，获取code
    public function index(){
        //获取新闻列表
        $newsModel                          = new NewsModel();
        $res['news_list']           = $newsModel->getList(['n.type' => ['in', '1,2'], 'status' => '1'], 1, 5);
        $res['notice_list']         = $newsModel->getList(['n.type' => ['in', '7'], 'status' => '1'], 1, 3);
        //时间和图片连接处理
        foreach ($res['news_list'] AS &$one){
            $one["pic"] = $one["pic"] . "?x-oss-process=style/list";
            $one["created_at"] = date("Y-m-d",$one["created_at"]);
        }
        foreach ($res['notice_list'] AS &$one){
            $one["pic"] = $one["pic"] . "?x-oss-process=style/list";
            $one["created_at"] = date("Y-m-d",$one["created_at"]);
        }
        $this->ajaxReturn($res);
    }

    public function strategy(){
        //获取新闻列表
        $newsModel                          = new NewsModel();
        $res['strategy_list']           = $newsModel->getList(['n.type' => ['in', '3'], 'status' => '1'], 1, 5);
        //时间和图片连接处理
        foreach ($res['strategy_list'] AS &$one){
            $one["pic"] = $one["pic"] . "?x-oss-process=style/list";
            $one["created_at"] = date("Y-m-d",$one["created_at"]);
        }
        $this->ajaxReturn($res);
    }
}